package cn.kn.sys.controller;

import cn.kn.common.model.R;
import cn.kn.sys.model.UserRole;
import cn.kn.sys.service.UserRoleService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author WangJiang
 * @create 2020-12-12 15:11
 */
@RestController
@RequestMapping("sys/userRole")
@RequiredArgsConstructor
public class UserRoleController {

    private final UserRoleService userRoleService;

    @GetMapping("/{userId}")
    public R getRoleIdsByUserId(@PathVariable Long userId){
        return userRoleService.getRoleIdsByUserId(userId);
    }

    @PostMapping("/{userId}/{roleNames}")
    public R save(@PathVariable Long userId, @PathVariable String roleNames, @RequestBody UserRole[] userRole){
        return userRoleService.save(userId,roleNames,userRole);
    }
}
